package utils;

import dao.UserMapper;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class UserDao {
    private volatile static UserMapper userMapper;

    private UserDao() {

    }

    public static UserMapper getInstance() {
        if (userMapper == null) {
            synchronized (UserDao.class) {
                if (userMapper == null) {
                    ApplicationContext ctx = new ClassPathXmlApplicationContext("classpath:applicationContext.xml");
                    userMapper = ctx.getBean(UserMapper.class);
                }
            }
        }
        return userMapper;
    }
}